//
//  NewsTableViewCell.m
//  WangI
//
//  Created by dllo on 15/11/23.
//  Copyright © 2015年 WJN. All rights reserved.
//

#import "NewsTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation NewsTableViewCell
-(void)dealloc {
    [_title release];
    [_labels release];
    [_images release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _title = [[UILabel alloc] initWithFrame:CGRectZero];
        _title.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:_title];
        [_title release];
        
        _images = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:_images];
        [_images release];
        
        _labels = [[UILabel alloc] initWithFrame:CGRectZero];
        _labels.font = [UIFont systemFontOfSize:15];
        //_labels.backgroundColor = [UIColor blueColor];
        _labels.numberOfLines = 0;
        _labels.alpha = 0.5;
        [self addSubview:_labels];
        [_labels release];
        _label = [[UILabel alloc] initWithFrame:CGRectZero];
        //_label.backgroundColor = [UIColor blueColor];
        [self addSubview:_label];
        [_label release];
    }
    return self;
}

-(void)setNewsModel:(NewsModel *)newsModel {
    if (_newsModel != newsModel) {
        [_newsModel release];
        _newsModel = [newsModel retain];
    }
    _labels.text = newsModel.digest;
    _title.text = newsModel.title;
    NSString *string = [NSString stringWithFormat:@"%@跟帖",newsModel.replyCount];
    
    _label.text = string;
    _label.alpha = 0.5;
    _label.textAlignment = NSTextAlignmentCenter;
    [_images sd_setImageWithURL:[NSURL URLWithString:newsModel.imgsrc]];
}

-(void)layoutSubviews {
    [super layoutSubviews];
    _images.frame = CGRectMake(5, 5, self.frame.size.height, self.frame.size.height - 10);
    _title.frame = CGRectMake(_images.frame.size.width + 5, 2, self.frame.size.width - _images.frame.size.width, 20);
    _labels.frame = CGRectMake(_images.frame.size.width + 5, 22, self.frame.size.width - _images.frame.size.width, _images.frame.size.height - 20);
    _label.frame = CGRectMake(320, 75, 100, 30);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
